<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.ionglobal.misc.*" %>

<%@ include file="../init_include.jsp" %>

<%
	Category cat;
	int catid;
	
	int check_rst=Permission.accept(dbi,session,request,"sysop","tree","catid","000000010"); 

	if (check_rst!=Permission.CHECK_RST_SUCCESS) {
		dbi.closeAll();
		if (check_rst==Permission.CHECK_RST_DENY)
			response.sendRedirect("../deny.html");
		else
			response.sendRedirect("../index.jsp");
		return;		
	}	
	
	String a=request.getParameter("catid");
	String str="";
	try {
		catid=Integer.parseInt(a);		
	} catch(NumberFormatException e) {
		out.println(e+"catId");
		return;
	}	
	
	Sysop sysop=(Sysop)session.getAttribute("sysop");	
	int ownid = sysop.getId(),userid=0;
	try {
		if (request.getParameter("userid")!=null)
			userid=Integer.parseInt(request.getParameter("userid"));
		else
			userid=ownid;
	}	catch(NumberFormatException e) {
		return ;
	}		
%>	
<html>
<head>
<title><%=Language.getNameByCode("sys.role.search","Search User And Privilege")%></title>
<meta http-equiv="Content-Type" content="text/html; charset=<%=Language.getHTMLLanguageStr()%>">
<link rel="stylesheet" href="../css.css" type="text/css">
<script Language="JavaScript" src="../script/Ion_Show.js"></script> 
<script language="javascript">
	function checkForm() {
		whereClause="";
		if(document.formIon.role.value!="-1")
			whereClause+=" and iRoleid="+document.formIon.role.value;
		if(document.formIon.group.value!="-1" && document.formIon.group.value!="")
			whereClause+=" and iClassid="+document.formIon.group.value;
		if(document.formIon.category.value!="-1" && document.formIon.category.value!="")
			whereClause+=" and iCategoryid="+document.formIon.category.value;
		whereClause+=" ";
		whereClause=whereClause.substring(4);
		setWhereClause(whereClause);
		closewindow(0);			
		close();
	}
</script>
</head>
<body bgColor=#d6d3ce leftMargin=0 
style="BORDER-BOTTOM: 0px outset; BORDER-LEFT: 0px outset; BORDER-RIGHT: 0px outset; BORDER-TOP: 0px outset" 
topMargin=0>
<form method="post" name="formIon" action="roleCommission_search.jsp" onSubmit="return checkForm();">
<%=Language.getNameByCode("sys.role.search","Search User And Privilege")%><hr>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
   <tr>
    <td><%=Language.getNameByCode("sys.role","Role")%>: </td>
    <td> 
      <select name="role">      
      	<option value="-1"><%=Language.getNameByCode("sys.all","all")%></option>
        <%
		  Vector vc=SysRole.getRoles(dbi,ownid);
			SysRole cr;
			String tmpStr="";
			String name="";
			int startvalue=1;
			if(Tree.checkSystem(dbi,userid))
				startvalue=0;

			for(int i=0;i<vc.size();i++)
			{	
				cr=(SysRole)vc.get(i);
				name=cr.getName(); //annia
				tmpStr+="<option value=\""+cr.getId()+ "\">" +name+"</option>\n";
			}
			out.println(tmpStr);
			%> 
      </select>
    </td>
  </tr>
 <tr> 
    <td><%=Language.getNameByCode("sys.sysop","User")%>:</td>
    <td><%=Language.getNameByCode("sys.category","Category")%>:</td>
 </tr>
 <tr>
    <td> 
      <select name="group" size="8">
      	<option value="-1"><%=Language.getNameByCode("sys.all","all")%></option>
        <%
	vc=ClassesDB.getChildrenByAsc(dbi,0,1,0);
	Classes group;
	name="";
	tmpStr="";
	for (int i=0;i<vc.size();i++)
	{	
		group=(Classes)vc.get(i);
		name=group.getName(); //annia
		tmpStr+="<option value=\""+group.getId()+ "\">" +name+"</option>\n";
	}
	out.println(tmpStr);
%> 
      </select>
    </td>
    <td> 
      <select name="category" size="8">
      	<option value="-1"><%=Language.getNameByCode("sys.all","all")%></option>
        <%
	vc=Tree.getLocalTree(dbi,0,ownid);
	Vector vcLad=new Vector();
	ItemData da,da1;
	for(int i=startvalue;i<vc.size();i++)
	{		
		da=(ItemData)vc.get(i);
		if (da.layer-startvalue>=vcLad.size())
			vcLad.add(da);
		else
			vcLad.set(da.layer-startvalue,da);
		if(da.haveLink) {
			tmpStr="<option value=\""+da.id+"\">";
			for (int k=0;k<=da.layer-startvalue;k++) {	
				da1=(ItemData)vcLad.get(k);
				tmpStr=tmpStr+da1.name+"--";
			}
			tmpStr=tmpStr.substring(0,tmpStr.lastIndexOf("--"));
			tmpStr+="</option>";
			out.println(tmpStr);
	}
	dbi.closeAll();
}
%> 
      </select>
    </td>
   </tr>
</table>
<input type="hidden" name="catid" value="<%=catid%>">
<input type="submit" name="Submit" value="<%=Language.getNameByCode("sys.Submit","Submit")%>">
</form>
</body>
</html>
<%@ include file="../init_free.jsp" %>	
